package com.medicine.hbp.adapter;

import org.kymjs.kjframe.KJBitmap;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.medicine.hbp.R;
import com.medicine.hbp.base.MyBaseAdapter;
import com.medicine.hbp.mob.findLaberAllByParentIdlistVo;
import com.medicine.hbp.ui.ClassificationDetailActivity;

public class FragmentAdapter02 extends MyBaseAdapter {
	private LayoutInflater inflater;
	private KJBitmap kjBitmap=new KJBitmap();

	public FragmentAdapter02(Activity activity) {
		this.activity=activity;
		inflater = LayoutInflater.from(activity);
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		viewHolder holder = null;
		if (view == null) {
			holder = new viewHolder();
			view = inflater.inflate(R.layout.item_fragment_02, arg2,false);
			holder.zt_title=(TextView) view.findViewById(R.id.zt_title);
			holder.zt_txt01=(TextView) view.findViewById(R.id.zt_txt01);
			holder.zt_txt02=(TextView) view.findViewById(R.id.zt_txt02);
			holder.img_backgroud=(ImageView) view.findViewById(R.id.img_backgroud);
			view.setTag(holder);
		} else {
			holder = (viewHolder) view.getTag();
		}
		final findLaberAllByParentIdlistVo vo=(findLaberAllByParentIdlistVo) getItem(position);
		if(vo!=null){
			holder.zt_title.setText(vo.laberNote);
			holder.zt_txt01.setText(vo.laberArtNumber+"");
			holder.zt_txt02.setText(vo.artCollectNumber+"");
			if(TextUtils.isEmpty(vo.laberImg)){
				holder.img_backgroud.setImageResource(R.mipmap.imgceshi2);
			}else{
				kjBitmap.display(holder.img_backgroud, vo.laberImg);
			}
			view.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					Intent intent=new Intent(activity,ClassificationDetailActivity.class);
					intent.putExtra("name", vo.laberNote);
					intent.putExtra("id", String.valueOf(vo.laberId));
					intent.putExtra("numone", String.valueOf(vo.laberArtNumber));
					intent.putExtra("numtwo", String.valueOf(vo.laberViewNumber));
					activity.startActivity(intent);
				}
			});
		}
		return view;
	}

	class viewHolder {
		TextView zt_title;
		TextView zt_txt01;
		TextView zt_txt02;
		ImageView img_backgroud;
	}

}
